import { reqGetSearchInfo, reqGoodsInfo } from '../../api'

const state = {
    goodInfo:{}
};
const mutations = {
    GETGOODINFO(state,goodInfo){
        state.goodInfo = goodInfo;
    }
};
const actions = {
    // 获取产品信息的action
   async getGoodInfo({commit},skuId){
       let result = await reqGoodsInfo(skuId);
       console.log(result);
       if(result.code == 200){
           commit('GETGOODINFO',result.data);

       }
    }
};
const getters = {
    // 路径高航简化的数据
    categoryView(state){
        return state.goodInfo.categoryView || {};
    },
    // 产品信息简化的数
    skuInfo(state){
        return state.goodInfo.skuInfo || {};
    },
    // 产品售卖属性的简化
    spuSaleAttrList(state){
        return state.goodInfo.spuSaleAttrList || [];
    }
};

export default{
    state,
    mutations,
    actions,
    getters
}